package calendar;

public class ShowUtil {
	public void showMonth(int month, CalendarUtil cu){
		int[] startPosition = new int[7];
		for(int i = 0; i < 7; i++){
			startPosition[i] = i * 6;
		}
		if(month < 1 || month > 12){
			return;
		}
		for(int i = 0; i < 7; i++){
			switch(i){
			case 0 : System.out.print("S");break;
			case 1 : System.out.print("M");break;
			case 2 : System.out.print("T");break;
			case 3 : System.out.print("W");break;
			case 4 : System.out.print("T");break;
			case 5 : System.out.print("F");break;
			case 6 : System.out.print("S");break;
			}
			for(int j = 0; j < 5; j++){
				System.out.print(" ");
			}
		}
		System.out.println();
		int startWeek = cu.getWeek(month);
		int daysOfMonth = cu.getDayOfMonth(month);
		int lineCharacterNum = 0;
		for(int i = 0; i < daysOfMonth; i++){
			while(lineCharacterNum < startPosition[startWeek]){
				lineCharacterNum++;
				System.out.print(" ");
			}
			System.out.print(i + 1);
			lineCharacterNum += (i + 1 + "").length();
			String symbol = cu.dayType(month, i + 1);
			System.out.print(symbol);
			lineCharacterNum += symbol.length();
			if(startWeek == 6){
				startWeek = 0;
				lineCharacterNum = 0;
				System.out.println();
			}else{
				startWeek++;
			}
		}
		System.out.println();
	}
	
	public void showAppointmentByDate(int month, int day, CalendarUtil cu){
		String str = cu.getAppointmentByDate(month, day);
		if(str.length() == 0){
			System.out.printf("There is no appointment on %d,%d", day, month);
		}else{
			System.out.println(str);
		}
	}
	
	public void showAppointmentByMonth(int month, CalendarUtil cu){
		String str = cu.getAppointmentByMonth(month);
		if(str.length() == 0){
			System.out.printf("There is no appointment in %d",  month);
		}else{
			System.out.println(str);
		}
	}
	
	public void showHolidaysByMonth(int month, CalendarUtil cu){
		String str = cu.getHolidaysByMonth(month);
		if(str.length() == 0){
			System.out.printf("There is no holidays in %d",  month);
		}else{
			System.out.println(str);
		}
	}
	
	public void showMainMenu(){
		System.out.println("Main menu");
		System.out.println("=========");
		System.out.println("1) Show calendar");
		System.out.println("2) Mark calendar");
		System.out.println("3) Exit");
		System.out.print(">>");
	}
	
	public void showMarkMenu(){
		System.out.println("Mark calendar");
		System.out.println("=============");
		System.out.println("1) Make appointment");
		System.out.println("2) Make weekly appointment");
		System.out.println("3) Delete appointment");
		System.out.println("4) Main menu");
		System.out.print(">>");
	}
	
	public void showShowMenu(){
		System.out.println("Show calendar");
		System.out.println("=============");
		System.out.println("1) Show month");
		System.out.println("2) Show appointment by date");
		System.out.println("3) Show appointment by month");
		System.out.println("4) Show holidays");
		System.out.println("5) Main menu");
		System.out.print(">>");
	}

}
